package org.example.sward.tooffer;

public class Offer50 {
    public static void main(String[] args) {
        Offer50 offer50 = new Offer50();
        double result =  offer50.myPow(2,-1);
        System.out.println(result);
    }
        public double myPow(double x, int n) {
            if(x == 0.0f){
                return 0d;
            }
            long b = n;
            double res  = 1.0;

            if(b < 0){
                x = 1/x;
                b = -b;
            }
            while(b > 0){
                if((b & 1) == 1){
                    res *= x;
                }
                x *= x;
                b >>= 1;
            }
            return res;
        }


}
